<template>
	<view class="body">
		<xk-header :headerbg="true" :back="true" title="预警"></xk-header>
		<view class="tabs-bar">
			<view v-for="(item, index) of tabs" :class="tabIndex === index ? 'item item-a' : 'item'" @click="clickTab(index)" >{{item.title}}</view>
		</view>

		<view class="list-info">
			<swiper :current="tabIndex" class="list-swiper"
				@change="(e)=>{this.tabIndex = e.target.current}"
				:style="{height: `${ scrollViewHeight }px;`}"> 
				<swiper-item v-for="(tabItem, tabIndex) of tabs" :key="tabIndex">
					<scroll-view class="data-list" scroll-y="true"
						v-if="dataList[tabIndex] && dataList[tabIndex].length > 0">
						<view class="data-item" v-for="(item, index) of dataList[tabIndex]"
							v-if="tabIndex === 0 || tabIndex === 1">
							<view class="item-top">
								<view  v-if="tabIndex === 0">合同编号:{{item.order}}</view>
								<view  v-if="tabIndex === 1">缴费单号:{{item.order}}</view>
								<view>{{item.date}}</view>
							</view>
							<view class="middle-view">
								<text  space="nbsp" class="content">{{item.content}}</text>
								<text  space="nbsp" class="timeout-date"  v-if="tabIndex === 0">
									截止日期：{{item.timeout}}
								</text>
								<text  space="nbsp" class="timeout-date"  v-if="tabIndex === 1">
									未缴费合同编号：{{item.timeout}}
								</text>
							</view>
							<view class="bottom-info-view">
								<view class="common-btn btn-sty2" v-if="tabIndex === 0"
									@click="goDetail(item)">查看合同</view>
								<view class="common-btn btn-sty2" v-if="tabIndex === 1"
									@click="goDetail(item)">查看详情</view>
							</view>
						</view>

						<view class="data-item-notice" v-for="item of dataList[tabIndex]"
							v-if="tabIndex === 2">
							<view class="time">{{item.date.split(" ")[1]}}</view>
							<view class="list-item" @click="goNoticeDetail(item)">
								<view class="title">{{item.title}}</view>
								<view class="sec-title-view">
									<view>{{item.author}}</view>
									<view>{{item.date.split(" ")[0]}}</view>
								</view>
								<text space="nbsp">{{item.content}}</text>
							</view>
						</view>
						<!-- <view class="data-item" v-for="(item, index) of dataList[tabIndex]"
							v-if="tabIndex === 2">
							<view class="item-top">
								<view  v-if="tabIndex === 0">合同编号:{{item.order}}</view>
								<view  v-if="tabIndex === 1">缴费单号:{{item.order}}</view>
								<view>{{item.date}}</view>
							</view>
							<view class="middle-view">
								<text  space="nbsp" class="content">{{item.content}}</text>
								<text  space="nbsp" class="timeout-date"  v-if="tabIndex === 0">
									截止日期：{{item.timeout}}
								</text>
								<text  space="nbsp" class="timeout-date"  v-if="tabIndex === 1">
									未缴费合同编号：{{item.timeout}}
								</text>
							</view>
							<view class="bottom-info-view">
								<view class="common-btn btn-sty2" v-if="tabIndex === 0"
									@click="goDetail(item)">查看合同</view>
								<view class="common-btn btn-sty2" v-if="tabIndex === 1"
									@click="goDetail(item)">查看详情</view>
							</view>
						</view> -->
					</scroll-view>

					<view class="empty-view" v-if="!dataList[tabIndex] || dataList[tabIndex] <= 0">
						<image class="empty-icon" :src="(imgUrl+'/wx/empty_data_icon.png')"></image>
						<view>哎呀，该界面暂无内容~</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>
<script>
	import config from '@/common/config.js'
	import moment from 'moment'

	export default {
		data() {
			return {
				imgUrl:this.$config.BASE_imgUrl,
				scrollViewHeight: 0,
				tabIndex: 0,
				tabs: [{
					index: 0,
					title: "合同预警"
				},{
					index: 1,
					title: "缴费预警"
				},
				// {
				// 	index: 2,
				// 	title: "重大事件"
				// },
				],
				dataList: [[{
					order: "HT202105310001",
					content: "尊敬的业主：\n      你好！您的合同即将到期，请您及时处理。",
					date: "05月30日 10:59",
					timeout: "2021年05月31日"
				}, {
					order: "HT202105310002",
					content: "尊敬的业主：\n      你好！您的合同即将到期，请您及时处理。",
					date: "05月30日 10:59",
					timeout: "2021年05月31日"
				}], [{
					order: "HT202105310001",
					content: "尊敬的业主：\n      你好！您的合同即将到期，请您及时处理。",
					date: "05月30日 10:59",
					timeout: "2021年05月31日"
				}, {
					order: "HT202105310002",
					content: "尊敬的业主：\n      你好！您的合同即将到期，请您及时处理。",
					date: "05月30日 10:59",
					timeout: "2021年05月31日"
				}],[{
					title: "关于广州新冠疫情防控通知",
					author: "物业管理处",
					date: "2020.10.17 08:59",
					content: "尊敬的业主：\n      你好！为进一步加强疫情防控工作，保障大家的人身安全，小区于明天开始将增加门禁权限管理。请广大业主积极配合！"
				}, {
					title: "关于进一步加强小区疫情防控工作通知",
					author: "物业管理处",
					date: "2020.10.17 08:59",
					content: "尊敬的业主：\n      你好！为进一步加强疫情防控工作，保障大家的人身安全，小区于明天开始将增加门禁权限管理。请广大业主积极配合！"
				}]]
			};
		},
		onLoad(options) {
		},
		onShow() {
			this.$util.getHeightWithTopEl(".tabs-bar").then(height => {
				this.scrollViewHeight = height - 20;
			});
		},
		methods:{
			clickTab(index){
				this.tabIndex = index
			},
			goDetail(item) {
				uni.navigateTo({
					url: "/pagesC/pay-order/pay-order-detail"
				})
			},
			goNoticeDetail(item) {
				uni.navigateTo({
					url: "/pagesC/notice/notice-detail"
				})
			}
		}
	}
</script>

<style lang="scss">
.tabs-bar{
	display: flex;
	align-items: center;
	flex-direction: row;
	justify-content: space-around;
	padding: 20rpx 30rpx 0rpx 30rpx;
	background-color: #FFFFFF;
	.item{
		height: 65rpx;
		align-items: center;
		justify-content: center;
		font-size: 32rpx;
		color: #333333;
		border-bottom: 6rpx solid rgba(#2C72FF, 0);
	}
	.item-a {
		font-weight: bolder;
		border-bottom: 6rpx solid #2C72FF;
	}
}


.list-info {
	.data-list{
		border-radius: 10rpx;
		height: 100%;
		.data-item{
			margin: 20rpx 30rpx;
			background-color: #ffffff;
			flex-direction: column;
			padding: 20rpx;
			font-size: 28rpx;
			.img{
				width: 335rpx;
				height: 250rpx;
				border-radius: 10rpx;
			}
			.item-top {
				display: flex;
				:first-child {
					flex: 1;
				}
				:last-child {
					color: #999;
					font-size: 24rpx;
				}
			}
			.middle-view{
				flex: 1;
				display: flex;
				flex-direction: column;
				padding: 20rpx 0rpx;
				font-size: 28rpx;

				.content{
					color: #666;
				}

				.timeout-date {
					margin-top: 5rpx;
					color: #FF3737;
					font-weight: bold;
				}

			}
			.bottom-info-view {
				display: flex;
				margin: 10rpx 0rpx;
				justify-content: flex-end;
				.common-btn{
					height: 60rpx;
					width: 160rpx;
					font-size: 28rpx;
					margin: 0;
				}
			}
		}
		.data-item-right {
			margin-right: 20rpx;
		}
	}

}

.data-item-notice {
	margin: 20rpx 20rpx 0rpx 20rpx;

	.time {
		text-align: center;
		color: #999;
		font-size: 24rpx;
	}

	.list-item {
		background-color: #FFFFFF;
		border-radius: 10rpx;
		font-size: 28rpx;
		color: #757A82;
		padding: 40rpx 30rpx 50rpx 30rpx;
		margin-top: 10rpx;

		.title {
			color: #333;
			font-size: 32rpx;
			font-weight: bold;
		}

		.sec-title-view {
			display: flex;
			margin: 20rpx 0rpx;
			align-items: center

			:first-child {
				font-size: 24rpx;
				color: #2C72FF;
			}
			:last-child {
				margin-left: 10rpx;
				color: #999;
				font-size: 24rpx;
			}
		}
	}
}

</style>
